package com.example.boot.rtgoods.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.boot.rtgoods.dao.RtGoodsDao;
import com.example.boot.rtgoods.model.RtGoods;
import com.example.boot.rtgoods.service.RtGoodsService;
import com.example.boot.rtgoods.vo.GoodsType;
import com.example.boot.rtshop.dao.RtShopDao;
import com.example.boot.rtshop.model.RtShop;

@Service
public class RtGoodsImpl implements RtGoodsService {
	@Autowired
	private RtGoodsDao rtGoodsDao;
	@Autowired
	private RtShopDao rtShopDao;

	@Override
	public RtShop byTableIdFindGoods(String tableId) throws Exception {
		RtShop byTableIdFindShop = rtShopDao.byTableIdFindShop(tableId);
		List<GoodsType> byShopFindGoodsType = rtGoodsDao.byShopFindGoodsType(byTableIdFindShop.getId());
		// List<List<RtGoods>> list = new ArrayList<>();
		for (GoodsType g : byShopFindGoodsType) {
			List<RtGoods> byTypeIdFindGoods = rtGoodsDao.byTypeIdFindGoods(g.getTypeId());
			g.setGoodsList(byTypeIdFindGoods);
		}
		byTableIdFindShop.setGoodsType(byShopFindGoodsType);
		// byTableIdFindShop.setGoodsType(list);

		return byTableIdFindShop;
	}

}
